package com.mcb_wxc.service.wxPay;

import java.io.InputStream;

/**
 * Created by 小生
 * 2019/4/13 9:50.
 */
public class WxPayConfigExt extends WXPayConfig {
    //微信开放平台审核通过的应用APPID
    private String appId = "wxfd753794e86d02d8";
    //微信支付分配的商户号
    private String  mchId = "1226127602";
    //商户的私钥
    private String key = "PmADGwX82e8lWU8bPmADGwX82e8lWxfj";
    //证书数据
    private byte[] certData;
    //微信请求域名
    private IWXPayDomain.DomainInfo domainInfo;
    //微信支付配置类子类实例
    private static WxPayConfigExt INSTANCE;

    private WxPayConfigExt() throws Exception{
//        String certPath = "src/resources/apiclient_cert.p12";//证书位置
//        File file = new File(certPath);
//        InputStream certStream = new FileInputStream(file);
//        this.certData = new byte[(int) file.length()];
//        certStream.read(this.certData);
//        certStream.close();
        domainInfo=new IWXPayDomain.DomainInfo(WXPayConstants.DOMAIN_API,true);
    }
    @Override
    public String getAppID() {
        return appId;
    }

    @Override
    public String getMchID() {
        return mchId;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public InputStream getCertStream() {
        return null;
    }

    @Override
    IWXPayDomain getWXPayDomain() {
        return new IWXPayDomainImp();
    }
    @Override
    public IWXPayDomain.DomainInfo getDomainInfo() {
        return domainInfo;
    }
    /**
     * 微信支付配置类子类实例
     * @return
     * @throws Exception
     */
    public static WxPayConfigExt getInstance() throws Exception{
        if (INSTANCE == null) {
            synchronized (WxPayConfigExt.class) {
                if (INSTANCE == null) {
                    INSTANCE = new WxPayConfigExt();
                }
            }
        }
        return INSTANCE;
    }
}
